﻿/*
 * Erstellt mit SharpDevelop.
 * Benutzer: Kai Patrick
 * Datum: 31.03.2008
 * Zeit: 18:35
 * 
 * Sie können diese Vorlage unter Extras > Optionen > Codeerstellung > Standardheader ändern.
 */

using System;
using Microsoft.Scripting;
using MSAst = Microsoft.Scripting.Ast;

namespace Gamadus.Engine.Compiler.Ast
{
	/// <summary>
	/// Description of Statement.
	/// </summary>
	public abstract class Statement : GmlNode
	{
        public Statement(Irony.Compiler.AstNode node) : base(node)
        {
        }
        
        public static Statement MakeStatement(Irony.Compiler.AstNode node)
		{
			switch(node.Term.Name)
			{
				case "Assignment":
					return new Assignment(node);
				case "Statement":
					return MakeStatement(node.ChildNodes[0]);
				case "FunctionExpression":
					return new ExpressionStatement(node);
				default:
					throw new ArgumentException("Invalid statement: "+node.Term.Name);
			}
		}

        internal protected abstract MSAst.Expression Generate();
	}
}
